package com.order.rec;

import com.order.appfood.domain.AppFood;
import com.order.appfood.service.IAppFoodService;
import com.order.appuser.domain.AppUser;
import com.order.appuser.service.IAppUserService;
import com.order.food.domain.OrderFood;
import com.order.food.service.IOrderFoodService;
import com.order.rec.enity.RecListEo;
import com.order.rec.enity.RecLunboEo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Api("App数据库接口")
@RestController
public class RecAppController {

    @Autowired
    private  IAppFoodService appFoodService;

    @Autowired
    private IAppUserService appUserService;

    @GetMapping("/app/rotation")
    @ApiOperation(notes = "App轮播图接口", value = "lunboInfo")
    public RecLunboEo rotation() {
        RecLunboEo rec = new RecLunboEo();

        rec.setStatus(0);

        RecLunboEo.MessageBean msg1 = new RecLunboEo.MessageBean();
        msg1.setId(1);
        msg1.setImg("http://img_hxyool.cn/lajiaosmwanyi.jpg");

        RecLunboEo.MessageBean msg2 = new RecLunboEo.MessageBean();
        msg2.setId(2);
        msg2.setImg("http://img_hxyool.cn/kaoya.jpg");

        RecLunboEo.MessageBean msg3 = new RecLunboEo.MessageBean();
        msg3.setId(3);
        msg3.setImg("http://img_hxyool.cn/jiaohuaji.jpg");

        RecLunboEo.MessageBean msg4 = new RecLunboEo.MessageBean();
        msg4.setId(4);
        msg4.setImg("http://img_hxyool.cn/malatang.jpg");


        RecLunboEo.MessageBean msg5 = new RecLunboEo.MessageBean();
        msg5.setId(5);
        msg5.setImg("http://img_hxyool.cn/maoxuewang.jpg");


        RecLunboEo.MessageBean msg6 = new RecLunboEo.MessageBean();
        msg6.setId(6);
        msg6.setImg("http://img_hxyool.cn/nanguatang.jpg");


        RecLunboEo.MessageBean msg7 = new RecLunboEo.MessageBean();
        msg7.setId(7);
        msg7.setImg("http://img_hxyool.cn/zhaxiaoyu.jpg");


        RecLunboEo.MessageBean msg8 = new RecLunboEo.MessageBean();
        msg8.setId(8);
        msg8.setImg("http://img_hxyool.cn/shaoji.jpg");


        List<RecLunboEo.MessageBean> list = new ArrayList<>();

        list.add(msg1);
        list.add(msg2);
        list.add(msg3);
        list.add(msg4);
        list.add(msg5);
        list.add(msg6);
        list.add(msg7);
        list.add(msg8);

        rec.setMessage(list);

        return rec;
    }


    @GetMapping("/app/applist")
    @ApiOperation(notes = "App主页美食", value = "listInfo")
    public  List<AppFood> applist() {

        List<AppFood> applist = appFoodService.selectAppFoodAll();

        return applist;
    }


    @PostMapping("/app/login")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "appuser",value = "登录用户名",required = true),
            @ApiImplicitParam(paramType = "query",name = "password",value = "登录密码",required = true)
    })
    @ApiOperation(notes = "App主页美食", value = "userInfo")
    public Object applogin (@ApiParam(name = "appuser",value = "登录用户名") String appuser,@ApiParam(name = "password",value = "密码") String password){

        AppUser appUser = appUserService.selectAppUserNamePass(appuser, password);

        if(appUser == null){
            return "用户名或密码错误！";
        }else{
            return appUser;
        }
    }
}
